package chapter06

object Demo04_Access {
  def main(args: Array[String]): Unit = {
    //创建对象
    val person: Person = new Person()
    println(person.age)
    person.printInfo()

    val worker: Worker = new Worker()
    worker.printInfo()
  }
}

//定义一个子类
class Worker extends Person {
  override def printInfo(): Unit ={
    println("Worker: ")
    name = "bob"
    age = 22
    sex = "male"

    println(s"Worker: $name $sex $age")
  }
}
